hvm qemu: Fix for masking 64-bit operands broke 32-bit operands with
authorKeir Fraser <keir@xensource.com>
Sun, 13 May 2007 09:04:34 +0000 (10:04 +0100)
committerKeir Fraser <keir@xensource.com>
Sun, 13 May 2007 09:04:34 +0000 (10:04 +0100)
32-bit qemu. Issue spotted and initial fix provided by Dexuan Cui.
Signed-off-by: Keir Fraser <keir@xensource.com>
tools/ioemu/target-i386-dm/helper2.c

index 637a3eb4a4bcc087120f166d071b680c1d50f132..46cdc547877097d8f2c1c332121bb47735a41340 100644 (file)
@@ -495,8 +495,12 @@ void cpu_ioreq_xchg(CPUState *env, ioreq_t *req)
 
 void __handle_ioreq(CPUState *env, ioreq_t *req)
 {
-    if (!req->data_is_ptr && (req->dir == IOREQ_WRITE) && (req->size != sizeof(req->data)))
-       req->data &= (1UL << (8 * req->size)) - 1;
+    if (!req->data_is_ptr && (req->dir == IOREQ_WRITE)) {
+        /* Clamp data operand to size of a long. */
+        if (req->size < sizeof(long))
+            req->data &= (1UL << (8 * req->size)) - 1;
+        req->data = (unsigned long)req->data;
+    }
 
     switch (req->type) {
     case IOREQ_TYPE_PIO: